module cl {
	export class LandIndexEngine {

		private _intTag : number = 0;

		private _indexToString(index : number) : string {
			index--;
			let y = Math.floor(index / 8);
			let x = index % 8;
			return "0" + y + "0" + x;
		}

		public reInit() : void {
			this._intTag = 0;
		}

		public setAllheadingTag() : void {
			this._intTag = 63;
		}

		public setLandTag(heading : number, boolSameType : boolean) : void {
			if (boolSameType){
				this._intTag += Math.pow(2, heading);
			}
		}

		public getIndexString() : string {
			if (this._intTag == 0){
				return this._indexToString(64);
			}else if (this._intTag == 63){
				return this._indexToString(65 + Math.floor(Math.random() * 16));
			}else{
				return this._indexToString(this._intTag);
			}
		}
	}

}